<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		//Submit Form
		$("#save").click(function() {
			$("#editTeamForm").submit();
		});
		
		//Copy Address From Parent
		var departmentId = getURLParameter("departmentId");
		$("#rdbParent").click(function(){
			$.ajax({
				url : 'getTeamAdressFromDepartment.action?departmentId=' + departmentId,
				success : function(data) {
					$("#addressLine1").val(data.address[0]);
					$("#addressLine2").val(data.address[1]);
					$("#addressLine3").val(data.address[2]);
					$("#postcode-lookup").val(data.address[3]);
					$("#city").val(data.address[4]);
					$("#county").val(data.address[5]);
					$("#selsear").val(data.address[6]);
				}
			});
		});
		
		//Copy Address From Organisation
		$("#rdbOrganisation").click(function(){
			alert("a");
			$.ajax({
				url : 'getTeamAdressFromOrganisation.action?departmentId=' + departmentId,
				success : function(data) {
					$("#addressLine1").val(data.address[0]);
					$("#addressLine2").val(data.address[1]);
					$("#addressLine3").val(data.address[2]);
					$("#postcode-lookup").val(data.address[3]);
					$("#city").val(data.address[4]);
					$("#county").val(data.address[5]);
					$("#selsear").val(data.address[6]);
				}
			});
		});
		
		//Get URL Parameter
		function getURLParameter(name) {
		    return decodeURI(
		        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
		    );
		}
	});
</script>

<div class="container-fluid">
	<div class="content">
		<div class="row-fluid">
			<div class="span12">
				<div class="box">
				
					<!-- BreadCrumbs -->
					<div class="box-head "> 
						<jsp:include page="breadCrumbs.jsp" >
						<jsp:param value="3" name="bc"/>
						</jsp:include>
					</div>
				
					<!-- Box -->
					
					<div class="box-head tabs">
						<div style="width: 280px;">
							<h3>Team Detail</h3>
							<ul class="nav nav-tabs" style="float: left; width: 280px">
								<li class='active'>
									<a href="#0" data-toggle="tab">Details</a>
								</li>
							</ul>
						</div>
						<div style="float: right;">
							<ul style="list-style: none;">
								<li style="float: left; margin-right: 10px;">
									<a id="mark-inactive" href="deActiveTeam.action?teamId=<s:property value='teamId'/>&departmentId=<s:property value="departmentId" />" class="btn btn-success">In-active</a>
								</li>
								<li style="float: left; margin-right: 10px;">
									<a id="save" href="#" class="btn btn-success">Save</a>
								</li>
								<li style="float: left;">
									<a id="" href="editDepartment.action?departmentId=<s:property value="departmentId" />&tab=listTeam" class="btn btn-success">Back</a>
								</li>
							</ul>
						</div>
					</div>
					<div class="box-content" id="organisation">
						<div class="tab-content">
							<div class="tab-pane active" id="0">
								<form id="editTeamForm" action="updateTeam.action?teamId=<s:property value="teamId" />&departmentId=<s:property value="departmentId" />" method="POST" class='validate form-horizontal'>
									<div class="row-fluid force-margin">
										<div class="span3">
											<div class="control-group">
												<label for="req" class="control-label require">Team Name</label>
												<div class="controls">
													<input type="text" name="name" id="req" class='required' value="<s:property value="teamBean.name"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Team Short Description</label>
												<div class="controls">
													<textarea style="resize: none;" rows="3" class="input-square" id="shortDescription" width="210px" name="shortDescription"><s:property value="teamBean.shortDescription"/></textarea>
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label require">Lead Contact</label>
												<div class="controls">
													<input type="text" name="contact" id="contact-name"
													class='input-medium input-square' disabled="disabled" value='<s:property value='teamBean.contact.firstname'/> <s:property value="teamBean.contact.surname"/>'>
													
													<input type="hidden" name="contactIden" id="contact-id" value='<s:property value="teamBean.contact.id"/>'/> 
													<a id="lookup-contact" data-toggle="modal" href="#lookUpContact">Lookup</a>
												</div>
											</div>
											<div class="control-group">
												<label for="radio2" class="control-label">Copy Address From</label>
												<div class="controls">
													<label class="radio" style="float: left;"><input type="radio" name="radio" class='uniform' id="rbdOrganisation" >Organisation</label>
													<label class="radio" style="float: left; padding: 5px 5px 5px 70px;"><input type="radio" class='uniform' name="radio" id="rbdParent">Parent</label>
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label v">Address Line 1</label>
												<div class="controls">
													<input type="text" name="addressLine1" id="addressLine1" class='required' value="<s:property value="teamBean.addressLine1"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Address Line 2</label>
												<div class="controls">
													<input type="text" name="addressLine2" id="addressLine2" class='required' value="<s:property value="teamBean.addressLine2"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Address Line 3</label>
												<div class="controls">
													<input type="text" name="addressLine3" id="addressLine3" class='required' value="<s:property value="teamBean.addressLine3"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label require">Post Code</label>
												<div class="controls">
													<input type="text" name="postcode" id="postcode-lookup" class='input-medium input-square' value="<s:property value="teamBean.postcode"/>">
													<a class="" id="lookup-postcode" data-toggle="modal" href="#lookUpPostcode">Lookup</a>
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Town/Village/City</label>
												<div class="controls">
													<input type="text" name="town" id="city" class='required' value="<s:property value="teamBean.town"/>">
												</div>	
											</div>
											<div class="control-group">
												<label for="req" class="control-label">County</label>
												<div class="controls">
													<input type="text" name="county" id="county" class='required' value="<s:property value="teamBean.county"/>">
												</div>
											</div>
											<div class="control-group">
											<label for="req" class="control-label">Nation/Country</label>
											<div class="controls">
												<s:select list="countries" name="countryId" listKey="countryId" 
														  listValue="countryName" id="selsear" class='cho' 
														  headerKey="-1" headerValue="" value="#{teamBean.country.countryId}">
												</s:select>
											</div>
										</div>
										</div>
										<div class="span3">
											<div class="control-group">
												<label for="req" class="control-label">Type of Bussiness</label>
												<div class="controls">
													<input type="text" name="bussinessType" id="txtBussinessName"
													class='input-medium input-square' disabled="disabled" value='<s:property value='teamBean.businessType.businessName'/>'>
													<a id="look-up" data-toggle="modal" href="#lookUpBusiness">Lookup</a>
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">SIC Code</label>
												<div class="controls">
													<input type="text" name="SIC Code" id="txtSICCode" disabled="disabled" value='<s:property value='teamBean.businessType.sICCode'/>'>
												</div>
											</div>
											<div class="control-group">
											</div>
											<div class="control-group">
											</div>
											<div class="control-group">
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Team Full Description</label>
												<div class="controls">
													<textarea style="resize: none;" rows="3" class="input-square" id="fullDescription" width="210px" name="fullDescription"><s:property value="teamBean.fullDescription"/></textarea>
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Phone Number</label>
												<div class="controls">
													<input type="text" name="phonenumber" id="phonenumber" class='required' value="<s:property value="teamBean.phonenumber"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Fax</label>
												<div class="controls">
													<input type="text" name="fax" id="req" class='required' value="<s:property value="teamBean.fax"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Email</label>
												<div class="controls">
													<input type="text" name="email" id="email" class='required' value="<s:property value="teamBean.email"/>">
												</div>
											</div>
											<div class="control-group">
												<label for="req" class="control-label">Web Address</label>
												<div class="controls">
													<input type="text" name="webAddress" id="webAddress" class='required' value="<s:property value="teamBean.webAddress"/>">
												</div>
											</div>
										</div>
										<div class="span12">
											<s:actionerror/>
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- Contact -->
<div id="pageLookUpContact"> 
	<%@ include file="lookUpContact.jsp" %>
</div>

<!-- BusinessType -->
<div id="pageLookupBusinessType"> 
	<%@ include file="LookupBusinessType.jsp" %>
</div>

<!-- Postcode -->
<div id="pageLookupPostcode">
	<%@ include file="lookUpPostcode.jsp" %>
</div>